/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package questao10;
/**
 *
 * @author SDKW
 */
public class ListaOrdenada extends Lista {
    
    public ListaOrdenada(IndiceOrdenacao indiceOrdenacao) {
        super(indiceOrdenacao);
    }
    
    @Override
    public void imprimir() {
        this.ordenaArrayList();
        this.indiceOrdenacao.imprimir(this.lista);
    }
    
    private void ordenaArrayList(){
        for (int j = 0; j < this.lista.size(); j++) {
            for (int i = j; i < this.lista.size(); i++ ) {
                if(this.lista.get(j).compareTo(this.lista.get(i)) > 0 ) {
                    String aux = this.lista.get(j);
                    this.lista.set(j,this.lista.get(i));
                    this.lista.set(i,aux);
                }  
            }
        }
    }
       
}
